package com.shimao.celnet.payment.service.impl;

import com.shimao.celnet.payment.mapper.PPayRefundMapper;
import com.shimao.celnet.payment.model.PPayRefund;
import com.shimao.celnet.payment.service.PPayRefundService;
import com.shimao.celnet.payment.util.FinalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 支付申请交易撤销 信息 管理
 * Created by christ on 2017/12/3.
 */
@Service
public class PPayRefundServiceImpl extends BaseServiceImpl<PPayRefund> implements PPayRefundService {
    @Autowired
    private PPayRefundMapper pPayRefundMapper;

    /**
     * 新增保存
     */
    @Override
    public int save(PPayRefund sBean) {
        int retCnt;
        sBean.setUpdateUserGuid(FinalUtil.INTER_FACE_USER_ID);
        sBean.setCreatedUserGuid(FinalUtil.INTER_FACE_USER_ID);
        sBean.setGuid(getGuid());//guid
        retCnt = super.save(sBean);
        return retCnt;
    }

    /**
     * 通过支付guid查询退款表
     */
    public PPayRefund selectListByMap(String payGuid) {
        Map<String, String> pMap = new HashMap<String, String>();
        pMap.put("payGuid", payGuid);
        List<PPayRefund> payRefundList = pPayRefundMapper.selectListByMap(pMap);
        PPayRefund pPayRefund = new PPayRefund();
        if (payRefundList.size() > 0) {
            pPayRefund = payRefundList.get(0);
        }
        return pPayRefund;
    }

    /**
     * 通过退款记录集合
     */
    @Override
    public List<PPayRefund> getRefundList() {

        return pPayRefundMapper.getRefundList();
    }
}
